/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ContentManagers.Security;

import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Ervin James
 */
public abstract class Authenticator {
    
    //parameters input = input from textfield / hash = hash from DB / salt = salt from DB
    public static boolean CompareHash(String input, String hash, String salt) {
        try {
            //convert salt to byte
            byte[] bSalt = Hasher.base64ToByte(salt);
            
            //hash password from input field
            input = Hasher.getHash(1, input, bSalt);
        } catch (NoSuchAlgorithmException ex) {
            Logger.getLogger(Authenticator.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Authenticator.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
        //return true or false
        return input.equals(hash);
    }
    
}
